
//LCP_28.采购方案
class Solution {
public:
    int purchasePlans(vector<int>& nums, int target) {
        int n=nums.size();
        sort(nums.begin(),nums.end());  //先进行排序
        int left=0,right=n-1;

        int ret=0;
        while(left<right)
        {
            if(nums[left]+nums[right]>target) right--;  //此时right的值不能与[left,right-1]任意一个值进行配对
            else 
            {
                ret=(ret+right-left)%1000000007;
                left++;
            }
        }
        return ret;
    }
};